<?php
 //----------------------------------------------------------------------
  // Sophia
  // Sophia by Alex Olave - http://www.alfazeta.cl
  //----------------------------------------------------------------------

  //----------------------------------------------------------------------
  // Author: 	Alex Olave - http://www.alfazeta.cl
  // Copyright: copyright (C) 2012 - Alex olave.
  // License: 	GNU/GPL, http://www.gnu.org/copyleft/gpl.html
  // Pack: 	Sophia
  //----------------------------------------------------------------------

  //----------------------------------------------------------------------
  // Sophia is free software. This version may have been modified pursuant
  // to the GNU General Public License, and as distributed it includes or
  // is derivative of works licensed under the GNU General Public License or
  // other free or open source software licenses.
  //----------------------------------------------------------------------


defined( '_JEXEC' ) or die( 'Restricted access' );

class nomHelperLoad
{
        function getAlumno($id) {
            $alumno = &JTable::getInstance('alumno', 'Table');
            $alumno->load($id);
            return $alumno;
        }

	function getlist($table = 'estudiantes') {
		$db = &JFactory::getDBO();
		$query = "SELECT * FROM #__sophia_".$table;
		$db->setQuery($query);
		return $db->loadObjectList();
	}

function getlist_Sexo($sexo) {
		$items[]		= JHTML::_('select.option',  'Masculino', JText::_( 'masculino' ), 'id', 'title' );
		$items[]		= JHTML::_('select.option',  'Femenino', JText::_( 'Femenino' ), 'id', 'title' );
        $javascript = '';
		$list		= JHTML::_('select.genericlist',   $items, 'sexo', 'class="inputbox" size="1"'.$javascript,'id', 'title', $sexo );
		return $list;
	}
     
function getlist_User($iduser, $gid = null) {
        $db = &JFactory::getDBO();
        $where = '';
        if ($gid != null) $where = " WHERE gid = ".$gid." AND block = 0";
        $query = "SELECT * FROM #__users".$where;
        $db->setQuery($query);
        $rowsi[] = JHTML::_('select.option',  '0', '- '.JText::_( 'No user' ).' -', 'id', 'username' );
        $rowsm = $db->loadObjectList();
        $rows = array_merge($rowsi, $rowsm);
        $list = JHTML::_('select.genericlist', $rows, 'iduser', 'class="inputbox" size="1"', 'id', 'username', $iduser);
        return $list;
    }	 
	
function getlist_Comuna($comuna_id,$name = 'comuna_id') {
        $db = &JFactory::getDBO();
		$query = $db->getQuery(true);
		$query->select('id as id , comuna as title');
		$query->from('#__sophia_comuna');
		$query->where('published = 1');
		$db->setQuery($query);

        $rowsi[] = JHTML::_('select.option',  '0', '- '.JText::_( 'Sin Comuna' ).' -', 'id', 'title' );
        $rowsm = $db->loadObjectList();
        $rows = array_merge($rowsi, $rowsm);
        $list = JHTML::_('select.genericlist', $rows, $name, 'class="inputbox" size="1"', 'id', 'title', $comuna_id);
        return $list;
    }
	
function getlist_Region($region_id,$name = 'region_id') {
        $db = &JFactory::getDBO();
        
		$query = $db->getQuery(true);
		$query->select('id as id , region as title');
		$query->from('#__sophia_region');
		$query->where('published = 1');
		$db->setQuery($query);
		
        $rowsi[] = JHTML::_('select.option',  '0', '- '.JText::_( 'Sin Region' ).' -', 'id', 'title' );
        $rowsm = $db->loadObjectList();
        $rows = array_merge($rowsi, $rowsm);
        $list = JHTML::_('select.genericlist', $rows, $name, 'class="inputbox" size="1"', 'id', 'title', $region_id);
        return $list;
    }
function getlist_Ciudad($ciudad_id,$name = 'ciudad_id') {
        $db = &JFactory::getDBO();
        

		$query = $db->getQuery(true);
		$query->select('id as id , ciudad as title');
		$query->from('#__sophia_ciudad');
		$query->where('published = 1');
		
		$db->setQuery((string)$query);
		$rowsi[] = JHTML::_('select.option',  '0', '- '.JText::_( 'Sin Ciudad' ).' -', 'id', 'title' );
        $rowsm = $db->loadObjectList();
		

        $rows = array_merge($rowsi, $rowsm);
        $list = JHTML::_('select.genericlist', $rows, $name, 'class="inputbox" size="1"', 'id', 'title', $ciudad_id);
        return $list;
    }
function getToolbarList() {
		
		//load the JToolBar library and create a toolbar
		jimport('joomla.html.toolbar');
		$bar =& new JToolBar( 'toolbar' );
		//and make whatever calls you require
		$bar->appendButton( 'Standard', 'new', 'Nuevo', 'add', false );
		$bar->appendButton( 'Separator' );
		$bar->appendButton( 'Standard', 'cancel', 'Cancel', 'cancel', false );
		$bar->appendButton( 'Separator' );
		$bar->appendButton( 'Standard', 'back', 'back', 'back', false );
		
		//generate the html and return
		return $bar->render();
	}

	
}// end Clase
